import numpy as np


class Tap:
    def __init__(self, category, img, des, vec):
        self.category: str = category
        self.img: str = img
        self.des: str = des
        self.vec: np.ndarray = vec

    def getVec(self) -> str:
        str1 = ','.join(str(x) for x in self.vec)
        return str1

    def getDis(self, target: np.ndarray) -> float:
        dis = np.sqrt(sum(np.power((self.vec - target), 2)))
        # dis = np.linalg.norm(self.vec - target)
        return dis

    def toJson(self) -> object:
        return {
            'category': self.category,
            'img': self.img,
            'description': self.des
        }